﻿using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Servicecomb.Saga.Omega.AspNetCore.Extensions;

namespace YDT_Distributed_Transaction.DistributedTransactions
{
    /// <summary>
    /// 分布式事务封装
    /// </summary>
    public static class OmegaDistributedTransactionWebApplicationBuilderExtenions
    {
        public static WebApplicationBuilder AddDistributedTransaction(this WebApplicationBuilder builder)
        {
           var Configuration = builder.Configuration;
            // 8、集成Omega
            builder.Services.AddOmegaCore(options =>
            {
                options.GrpcServerAddress = Configuration["DistributedTransaction:GrpcServerAddress"];
                options.ServiceName = Configuration["DistributedTransaction:ServiceName"];
                options.InstanceId = Configuration["DistributedTransaction:InstanceId"];
            });
            return builder;
        }
    }
}
